package com.yuexun.beilunpatient.ui.satisfaction.presenter.impl;

import com.yuexun.beilunpatient.base.BaseEntity;
import com.yuexun.beilunpatient.ui.satisfaction.bean.SatisfactionDateBean;
import com.yuexun.beilunpatient.ui.satisfaction.model.ISatisfactionModel;
import com.yuexun.beilunpatient.ui.satisfaction.presenter.ISatisfactionPresenter;
import com.yuexun.beilunpatient.ui.satisfaction.ui.view.ISatisfactionView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenss on 2018/7/31 0031.
 */

public class SatisfactionPresenter implements ISatisfactionPresenter {

    private ISatisfactionView view;
    private ISatisfactionModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public SatisfactionPresenter(ISatisfactionModel model, ISatisfactionView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void inquireUserSurveyPageList(Map<String, String> praise) {
        model.inquireUserSurveyPageList(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<SatisfactionDateBean>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("查询满意度失败");
                    }

                    @Override
                    public void onNext(BaseEntity<SatisfactionDateBean> entity) {
                        view.showSatisfactionPageList(entity);
                    }
                });
    }
}
